<?php 
require_once(sfConfig::get('sf_plugins_dir').'/sfDoctrineGuardPlugin/lib/form/doctrine/base/BasesfGuardRegisterForm.class.php');



class sfGuardRegisterForm extends BasesfGuardRegisterForm
{
  public function configure()
  {
       
     
      $userDetails = new GofishPlayer();
      $userDetails->sfGuardUser = $this->getObject();  // Users AKA sfGuardUser
      

      $formDetails = new GofishPlayerForm($userDetails);
      //$formDetails->setWidget('sf_guard_user_id', new sfWidgetFormInputHidden(array(), array('value' => $this->getValue('id'))));

      $this->validatorSchema['username'] = new sfValidatorString(array
          ('required' => true), array('required' => 'This field is mandatory'));
      $this->validatorSchema['password'] = new sfValidatorString(array
          ('min_length' => 6), array('min_length' => 'minimum length is 6 characters'));
      $this->validatorSchema['password_again'] = new sfValidatorString(array
          ('min_length' => 6), array('min_length' => 'minimum length is 6 characters'));
      $this->validatorSchema['email_address'] = new sfValidatorString(array
          ('required' => true), array('required' => 'This field is mandatory.'));
      $this->validatorSchema['email_address'] = new sfValidatorAnd(array(
          $this->validatorSchema['email_address'], 
          new sfValidatorString(array(), array('invalid' => 'The email is invalid.')))
              );
      $this->validatorSchema['username'] = new sfValidatorAnd(array(
            $this->validatorSchema['username'],
            new sfValidatorDoctrineUnique(
            array( 'model' => 'sfGuardUser',
                   'column' => 'username',
                   'primary_key' => 'id',
                   'throw_global_error' => true),
            array( 'invalid' => 'username exists' )
          )));
          
      $this->validatorSchema['email_address'] = new sfValidatorAnd(array(
          $this->validatorSchema['email_address'],
          new sfValidatorEmail()
          ));
          
      $this->validatorSchema->setPostValidator(
          new sfValidatorSchemaCompare('password', sfValidatorSchemaCompare::EQUAL, 'password_again',
            array('throw_global_error' => false),
            array('invalid' => 'The two password inserted do not match.')
          )
        );
      
      $this->embedRelation('Player' );
  }
  
  protected function doSave($con = null)
  {
      return parent::doSave($con);
  }


}
?>